<!DOCTYPE HTML>
<html th:with="title='编辑模板类型'">
<head th:include="fragments/UEheader :: header">
</head>
<body id="app">
	<div class="page-container">
		<form action="/manager/templateType/update" method="post" class="form form-horizontal" id="templateType-form">
			<input type="hidden" name="id" v-model="templateType.id" />
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">
					<span class="c-red">*</span>
					名称：
				</label>
				<div class="formControls col-xs-3 col-sm-3">
					<input type="text" class="input-text size-L" v-model="templateType.templateTypeName" id="templateTypeName" name="templateTypeName">
				</div>
			</div>
						<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">
					<span class="c-red">*</span>
					模板类别编码：
				</label>
				<div class="formControls col-xs-3 col-sm-3">
					<input type="text" class="input-text size-L" v-model="templateType.templateTypeSn" id="templateTypeSn" name="templateTypeSn">
				</div>
			</div>
			<div class="row cl">
				<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
					<input class="btn btn-primary size-L radius" type="submit" value="提交">
					<input class="btn btn-primary size-L radius" type="button" onclick="closeWin()" value="关闭">
				</div>
			</div>
		</form>
	</div>

	<script type="text/javascript">
		var app = new Vue({
			el : '#app',
			data : {
				templateType : []
			}
		});
		function closeWin() {
			var index = parent.layer.getFrameIndex(window.name);
			parent.layer.close(index);
		}
		$(function() {
			/* 初始化单选框样式 */
			get();
			$('.skin-minimal input').iCheck({
				checkboxClass : 'icheckbox-blue',
				radioClass : 'iradio-blue',
				increaseArea : '20%'
			});
			$("#templateType-form").validate({
				rules : {
					templateTypeName : {
						required : true
					}
				},
				onkeyup : false,
				focusCleanup : true,
				success : "valid",
				submitHandler : function(form) {
					var data = $('#templateType-form').serialize();
					$.ajax({
						type : "POST",
						url : '/manager/templateType/update',
						data : data,
						beforeSend : function() {

						},
						complete : function() {

						},
						error : function(request) {
							layer.alert("系统出错");
						},
						success : function(data) {
							if (data.status == 0) {
								refreshUParentList();
								layer.alert(data.message, function() {
									var index = parent.layer.getFrameIndex(window.name);
									parent.layer.close(index);
								});
							} else {
								layer.alert(data.message);
							}
						}
					});
				}
			});
		});
		function getIdFromUrl() {
			var addr = location.href;
			var index = addr.lastIndexOf('/') + 1;
			var id = addr.substr(index);
			return id;
		}
		//获取当前营销详情
		function get() {
			var id = getIdFromUrl();
			$.ajax({
				type : "POST",
				url : '/manager/templateType/get/' + id,
				beforeSend : function() {
				},
				complete : function() {
				},
				error : function(request) {
					alert("Connection error");
				},
				success : function(result) {
					if (result.status == 0) {
						var data = result.data;
						app.templateType = data;
					}
				}
			});
		}
	</script>
</body>
</html>